package com.cly.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * 把eureka保护起来
 * 不能让给其他人随意访问
 * 检查健康端口要放行
 */
@Configuration
public class EurekaWebSecurityConfig extends WebSecurityConfigurerAdapter {

    /**
     * 配置http放行
     * @param http
     * @throws Exception
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //关闭跨站请求攻击
        http.csrf().disable();
        //放行健康检查端口
        http.authorizeRequests().antMatchers("/actuator/**").permitAll();
        super.configure(http);
    }
}
